package com.zl.learning.arithmetic.data_structure;

import lombok.Data;

@Data
public class Node {
    private Integer data;
    private Node left;
    private Node right;

    public Node(Integer data, Node left, Node right) {
        this.data = data;
        this.left = left;
        this.right = right;
    }

    public void preOrder() {
        preVisit(this);
    }

    public void preVisit(Node node) {
        System.out.println(node.getData());
        if (node.getLeft() != null) {
            preVisit(node.getLeft());
        }
        if (node.getRight() != null) {
            preVisit(node.getRight());
        }
    }

}
